const express = require("express");
const expressStatic = require("express-static");
const bodyparse = require("body-parser");

var server = express();
server.listen(8080);

//定义接口
//  /login?user=xxy&pass=123

//用户数据
var users={
	"adrain":'123456',
	'zhangsan':'zhangsan'
}

server.get("/login",function (req,res) {
	var user = req.query['user'];
	var pass = req.query['pass'];

	if(users[user]==null){
		res.send({ok:false,msg:'此用户不存在'});
	}else{
		if(users[user]!=pass){
			res.send({ok:false,msg:'密码错了'})
		}else {
			res.send({ok:true,msg:'成功'})
		}
	}

})

server.use(expressStatic('./www'));